﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DB_NH.DB_Map.SimpleFlow
{
    using NHibernate;
    using NHibernate.Mapping.ByCode;
    using NHibernate.Mapping.ByCode.Conformist;

    using DB_NH.DB_Model.SimpleFlow;

    public class map_ApprovalToDo : EntityMapping<ApprovalToDo>
    {
        public map_ApprovalToDo()
        {
            Property(x => x.Title, map =>
            {
                map.Length(200);
            });

            Property(x => x.Tag, map =>
            {
                map.Length(200);
            });

            //待办所属审批记录
            ManyToOne(x => x.Record, map =>
            {
                map.Column("RecordID");
            });

            //待办记录对应的用户操作列表（多对多）
            Bag(x => x.ToDoUsers, map =>
            {
                map.Table("ref_ToDo_User");
                map.Key(keyMapper => keyMapper.Column("ToDoId"));
            }, act => act.ManyToMany(m => m.Column("UserId")));

            //待办记录对应的邮件操作列表（多对多）
            Bag(x => x.ToDoMails, map =>
            {
                map.Table("ref_ToDo_Mail");
                map.Key(keyMapper => keyMapper.Column("ToDoId"));
            }, act => act.ManyToMany(m => m.Column("MailId")));
        }
    }
}
